<template>
  <div class="logo">
    <router-link :to="{name:'Console'}">
<!--      <LogoSvg alt="logo"  style="width: 150px;height: 30px;color:#fff;padding-left: 10px"/>-->
      <span class="companyTitle">{{companyTitle  || '运车宝'}}</span>
      <h1 v-if="showTitle" style="padding-top: 10px;color: #ffffffb3">{{ this.titles }}v3.0.0</h1>
    </router-link>
  </div>
</template>

<script>
import LogoSvg from '@/assets/logo.svg?inline'
import { mixin, mixinDevice } from '@/utils/mixin'

export default {
  name: 'Logo',
  components: {
    LogoSvg
  },
  mixins: [mixin, mixinDevice],
  data () {
    return {
      titles: '',
      companyTitle: ''
    }
  },
  props: {
    title: {
      type: String,
      default: '',
      required: false
    },
    showTitle: {
      type: Boolean,
      default: true,
      required: false
    }
  },
  created () {
    // 将本地存储的对象转成json对象
    const username = JSON.parse(localStorage.getItem("pro__COMPANY_NAME"));
   this.companyTitle = username.value;
    if (this.layoutMode === 'topmenu') {
      if (this.title.length > 8) {
        this.titles = this.title.substring(0, 7) + '...'
      } else {
        this.titles = this.title
      }
    } else {
      if (this.title.length > 10) {
        this.titles = this.title.substring(0, 9) + '...'
      } else {
        this.titles = this.title
      }
    }
  }
}
</script>

<style scoped>
.companyTitle{
  font-size: 30px;
  font-family: cursive;
  font-weight: bold;
  color: #fff;
  padding-left: 10px;
}
</style>